package com.study.tx.mixture;

import com.study.tx.common.listener.*;
import com.study.tx.common.utils.ApplicationContextUtils;
import org.springframework.context.annotation.*;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Spring 事务配置类。注意：
 * 1、@EnableTransactionManagement 的功能就是启用注解事务管理，等同于 xml 配置中的 <tx:annotation-driven/>
 * 2、@@ComponentScan 的功能就是指定扫描的包，等同于 xml 配置中的 <context:component-scan/>
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2021年02月02日
 */
@Configuration
@EnableTransactionManagement(proxyTargetClass = false)
@ImportResource(value = {"classpath*:com/study/tx/spring-tx-mixture.xml"})
//@ComponentScan(value = {"com.study.tx.mixture.dao", "com.study.tx.mixture.service"})
public class MixtureTxConfig {
    @Bean
    public ApplicationContextUtils applicationContextUtils() {
        ApplicationContextUtils applicationContextUtils = new ApplicationContextUtils();
        return applicationContextUtils;
    }

    @Bean
    public MyTransactionListener myTransactionListener() {
        MyTransactionListener myTransactionListener = new MyTransactionListener();
        return myTransactionListener;
    }

    @Bean
    public MyTransactionEventListener myTransactionEventListener() {
        MyTransactionEventListener myTransactionEventListener = new MyTransactionEventListener();
        return myTransactionEventListener;
    }

    @Bean
    public MyOrderTransactionEventListener myOrderTransactionEventListener() {
        MyOrderTransactionEventListener myOrderTransactionEventListener = new MyOrderTransactionEventListener();
        return myOrderTransactionEventListener;
    }

    @Bean
    public MyOrderItemTransactionEventListener myOrderItemTransactionEventListener() {
        MyOrderItemTransactionEventListener myOrderItemTransactionEventListener = new MyOrderItemTransactionEventListener();
        return myOrderItemTransactionEventListener;
    }
}
